export  default class GAMEFUNC_ {

    //GAMEFUNC_类


    static INSTANCE_CLASS = {

        GET_PICK_INSTANCE(a, runtime) {


            const ins = runtime.objects[a];
            for (const insins of ins.getPickedInstances()) {
                return insins;
            }
        },


        CHANGE_INSTANCE_POSITION(ins, x, y) {
            ins.x = x
            ins.y = y

        },

     
    }


    static waitTime(ms) {
        return new Promise(res => setTimeout(res, ms));
    }


    static repeatEvery(f, ms) {
        return new Promise(res => setInterval(f, ms));
    }


    // await waitTime(1000);
    // repeatEvery(() => {console.log(Math.random())}, 1000);




    static RUNTIME_TIME_EVENTS_={

        flowListener(runtime) {


        },




        async FLOW_ACTIVE_TRANSPORT(ACTIVE_TIMES){

            await GAMEFUNC_.waitTime(ACTIVE_TIMES)

        },




    }

    static EvenetRuntime = {

        ACtiveEventHandlerGroup(runtime, g_name) {
            runtime.callFunction("ACTIVE_GROUP", g_name)

        },

        CloseEventHandlerGroup(runtime, g_name) {
            runtime.callFunction("CLOSE_GROUP", g_name)

        }

    }

    static MOUSE_RUNTIME_ = {

        getX(runtime) {
            return runtime.callFunction("GET_MOUSE_POSITION", "x")
        },

        getY(runtime) {
            return runtime.callFunction("GET_MOUSE_POSITION", "y")
        },


    }


    static RUNTIME = {


        IN_GAME_LAYOUT(runtime) {
            let layoutName = GAMEFUNC_.RUNTIME.GET_RUNTIME_LAYOUT(runtime)
            if (layoutName == "Game") {
                return true
            } else {
                return false
            }
        },


        GET_RUNTIME_LAYOUT(runtime) {
            return runtime.layout.name
        },


        lerp(runtime, x, y, time) {
            return runtime.callFunction("Lerp", x, y, time)
        },

    }



    static MATH = {

        GET_DISTANCE(runtime, P1X, P1Y, P2X, P2Y) {
            return runtime.callFunction("GET_DIS_FROMPOS", P1X, P1Y, P2X, P2Y)
        }
    }





}



